attobo.pilot$Age[attobo.pilot$Age == 1943] <- 75
attobo.pilot$Age[attobo.pilot$Age == 1984] <- 34
attobo.pilot$Age[attobo.pilot$Age == 1987] <- 31
attobo.pilot$Age[attobo.pilot$Age == 1988] <- 32
attobo.pilot$Age[attobo.pilot$Age == 1992] <- 26

summary(attobo.pilot$Age)
##    Min. 1st Qu.  Median    Mean 3rd Qu.    Max.    NA's 
##    5.00   28.00   30.00   33.16   36.00   76.00       2
sd(attobo.pilot$Age, na.rm = T)
## [1] 10.3625
summary(factor(attobo.pilot$Gender))
##   1   2   3 
## 125  76   1
attobo.pilot$row.id <- 1:202

attobo.locus.long <- data.frame(
  
  locus = c(attobo.pilot$AptOut, attobo.pilot$EffortOut, attobo.pilot$StratOut),
  id = rep(attobo.pilot$row.id, 3),
  attribution = c(rep("Aptitude", 202), rep("Effort", 202), rep("Strategy", 202))
  # effort = c(rep(0, 202), rep(1,202), rep(0, 202)), 
  # strategy = c(rep(0, 202), rep(0,202), rep(1, 202)), 
  # effort = c(rep(1, 202), rep(0,202), rep(0, 202))
  
)

attobo.var.long <- data.frame(
  
  var = c(attobo.pilot$AptVar, attobo.pilot$EffortVar, attobo.pilot$StratVar),
  id = rep(attobo.pilot$row.id, 3),
  attribution = c(rep("Aptitude", 202), rep("Effort", 202), rep("Strategy", 202))
  
)

attobo.uncon.long <- data.frame(
  
  uncon = c(attobo.pilot$AptUncon, attobo.pilot$EffortUncon, attobo.pilot$StratUncon),
  id = rep(attobo.pilot$row.id, 3),
  attribution = c(rep("Aptitude", 202), rep("Effort", 202), rep("Strategy", 202))
  
)

Descriptive Stats

attobo.pilot %>%
  summarise(AptOutMean = mean(AptOut, na.rm = T),
            EffortOutMean = mean(EffortOut, na.rm = T),
            StratOutMean = mean(StratOut, na.rm = T),
            AptOutSD = sd(AptOut, na.rm = T),
            EffortOutSD = sd(EffortOut, na.rm = T),
            StratOutSD = sd(StratOut, na.rm = T))
attobo.pilot %>%
  summarise(AptVarMean = mean(AptVar, na.rm = T),
            EffortVarMean = mean(EffortVar, na.rm = T),
            StratVarMean = mean(StratVar, na.rm = T),
            AptVarSD = sd(AptVar, na.rm = T),
            EffortVarSD = sd(EffortVar, na.rm = T),
            StratVarSD = sd(StratVar, na.rm = T))
attobo.pilot %>%
  summarise(AptUnconMean = mean(AptUncon, na.rm = T),
            EffortUnconMean = mean(EffortUncon, na.rm = T),
            StratUnconMean = mean(StratUncon, na.rm = T),
            AptUnconSD = sd(AptUncon, na.rm = T),
            EffortUnconSD = sd(EffortUncon, na.rm = T),
            StratUnconSD = sd(StratUncon, na.rm = T))
attobo.dimensions <- attobo.pilot[, 2:19]

ggplot(data = gather(attobo.dimensions , factor_key = TRUE), aes(x = factor(value))) +
  geom_bar() + 
  facet_wrap(~ key,scales = "free", as.table = TRUE, nrow = 3) + xlab("") + 
  theme_bw()

Attribution Patterns

Locus

Frequentist Estimates

t.test(attobo.pilot$EffortOut, attobo.pilot$AptOut, paired = TRUE)
## 
##  Paired t-test
## 
## data:  attobo.pilot$EffortOut and attobo.pilot$AptOut
## t = 0.861, df = 201, p-value = 0.3903
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
##  -0.07664409  0.19545598
## sample estimates:
## mean of the differences 
##              0.05940594
t.test(attobo.pilot$StratOut, attobo.pilot$AptOut,paired = TRUE)
## 
##  Paired t-test
## 
## data:  attobo.pilot$StratOut and attobo.pilot$AptOut
## t = 3.3683, df = 201, p-value = 0.0009065
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
##  0.1046725 0.4002780
## sample estimates:
## mean of the differences 
##               0.2524752
t.test(attobo.pilot$StratOut, attobo.pilot$EffortOut, paired = TRUE)
## 
##  Paired t-test
## 
## data:  attobo.pilot$StratOut and attobo.pilot$EffortOut
## t = 2.7273, df = 201, p-value = 0.00695
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
##  0.05348143 0.33265718
## sample estimates:
## mean of the differences 
##               0.1930693

Bayesian Model - Locus

apt.out <- attobo.pilot$AptOut
eff.out <- attobo.pilot$EffortOut
strat.out <- attobo.pilot$StratOut

y <- c(apt.out, eff.out, strat.out)
grand.mean <- mean(y, na.rm = T)

attobo.pilot.datjags <- list(apt.out = apt.out, eff.out = eff.out, strat.out = strat.out, N = nrow(attobo.pilot), grand.mean = grand.mean)
attobo.pilot.datjags

Model Specification

attobo.pilot.model <- function() {
  for(i in 1:N){
    # lambda is mean and variance of the poisson distribution
    
    apt.out[i] ~ dnorm(mu.apt[i], sigma[i]) # fixing error from each participant to be the same
    eff.out[i] ~ dnorm(mu.eff[i], sigma[i])
    strat.out[i] ~ dnorm(mu.strat[i], sigma[i])
    sigma[i] ~ dgamma(.01, .01) # all errors come from same distribution
  
    diff[1, i] <- mu.eff[i] - mu.apt[i]
    diff[2, i] <- mu.strat[i] - mu.apt[i]
    diff[3, i] <- mu.strat[i] - mu.eff[i]

    #priors
    mu.apt[i] ~ dnorm(grand.mean, .01)
    mu.eff[i] ~ dnorm(grand.mean, .01)
    mu.strat[i] ~ dnorm(grand.mean, .01)
    
  }
   
  
}
attobo.pilot.params <- c("diff", "mu.apt", "mu.eff", "mu.strat", "sigma")
attobo.pilot.inits1 <-  list( "mu.apt" =  rep(grand.mean, 202),
                        "mu.eff" = rep(grand.mean, 202), 
                        "mu.strat" = rep(grand.mean, 202),
                        "sigma" = rep(1,202))
attobo.pilot.inits2 <- list( "mu.apt" =  rep(3.5, 202),
                        "mu.eff" = rep(3.5, 202), 
                        "mu.strat" = rep(3.5, 202),
                        "sigma" = rep(2,202))
attobo.pilot.inits3 <- list( "mu.apt" =  rep(5, 202),
                        "mu.eff" = rep(5, 202), 
                        "mu.strat" = rep(5, 202),
                        "sigma" = rep(3,202))
attobo.pilot.inits4 <- list( "mu.apt" =  rep(2.5, 202),
                        "mu.eff" = rep(2.5, 202), 
                        "mu.strat" = rep(2.5, 202),
                        "sigma" = rep(1,202))
attobo.pilot.inits5 <- list( "mu.apt" =  rep(6, 202),
                        "mu.eff" = rep(6, 202), 
                        "mu.strat" = rep(6, 202),
                        "sigma" = rep(5,202))

attobo.pilot.inits <- list(attobo.pilot.inits1, attobo.pilot.inits2,attobo.pilot.inits3, attobo.pilot.inits4,attobo.pilot.inits5)
set.seed(1128)
attobo.pilot.fit <- jags(data = attobo.pilot.datjags, inits = attobo.pilot.inits, parameters.to.save = attobo.pilot.params, 
                n.chains = 5, n.iter = 100000, n.burnin = 10000, model.file = attobo.pilot.model)

attobo.pilot.fit.upd <- update(attobo.pilot.fit, n.iter =1000)
attobo.pilot.fit.upd <- autojags(attobo.pilot.fit)
attobo.pilot.fit.mcmc <- as.mcmc(attobo.pilot.fit)
save(attobo.pilot.fit.mcmc, file = "attobo.pilot.locus.mcmc.RData")
summary(attobo.pilot.fit.mcmc)

Convergence Diagnostics

load("attobo.pilot.locus.mcmc.RData")

#  15 traces
MCMCtrace(attobo.pilot.fit.mcmc[,1:15], ind = TRUE, pdf = FALSE )

autocorr.plot(attobo.pilot.fit.mcmc[1][,1:15], ask = FALSE)

autocorr.plot(attobo.pilot.fit.mcmc[2][,1:15], ask = FALSE)

autocorr.plot(attobo.pilot.fit.mcmc[3][,1:15], ask = FALSE)

autocorr.plot(attobo.pilot.fit.mcmc[4][,1:15], ask = FALSE)

autocorr.plot(attobo.pilot.fit.mcmc[5][,1:15], ask = FALSE)

Calculating quantiles

attobo.pilot.out <- as.data.frame(as.matrix(attobo.pilot.fit.mcmc))
save(attobo.pilot.out, file = "attobo.pilot.locus.RData")
load("attobo.pilot.locus.RData")

pred.diff <- attobo.pilot.out[, grep("diff[", colnames(attobo.pilot.out), fixed = T)]

## estimated difference for each participant
pred.diff <- pred.diff[, c(mixedsort(names(pred.diff)))]

diff.1 <- pred.diff[, 1:202]
diff.1$mean.1 <- apply(diff.1, 1, mean)

diff.2 <- pred.diff[, 203:404]
diff.2$mean.2 <- apply(diff.2, 1, mean)

diff.3 <- pred.diff[, 405:606]
diff.3$mean.3 <- apply(diff.3, 1, mean)

# no clear diff
quantile(diff.1$mean.1, probs = c(.025, .5, .975))
##        2.5%         50%       97.5% 
## -0.50196121  0.05190618  0.60508972
# no clear diff
quantile(diff.2$mean.2, probs = c(.025, .5, .975))
##       2.5%        50%      97.5% 
## -0.3222280  0.2266773  0.7757629
# no clear diff
quantile(diff.3$mean.3, probs = c(.025, .5, .975))
##       2.5%        50%      97.5% 
## -0.3843197  0.1724080  0.7229226

Presenting Results

attobo.pilot.posterior.coefs <- cbind(diff.1$mean.1, diff.2$mean.2, diff.3$mean.3)
attobo.pilot.posterior.coefs <- as.data.frame(attobo.pilot.posterior.coefs)
names(attobo.pilot.posterior.coefs) <- c("Effort - Aptitude", "Strategy - Aptitude", "Strategy - Effort")

attobo.pilot.posterior.coefs.long <- gather(attobo.pilot.posterior.coefs)
attobo.pilot.posterior.coefs.sum <- summarize(group_by(attobo.pilot.posterior.coefs.long, key),
                                        median_coef = median(value),
                                        lower_coef = quantile(value, probs = c(0.025)),
                                        upper_coef = quantile(value, probs = c(0.975)))
ggplot(data = attobo.pilot.posterior.coefs.sum, aes(x = median_coef, y = key)) + 
  geom_errorbarh(aes(xmin = lower_coef, xmax = upper_coef), height = 0.1) + 
  geom_point() + 
  geom_vline(xintercept = 0, linetype = "dashed") + 
  xlab("Posterior estimate") + ylab("") + 
  theme_bw()

Variability

Frequentist Estimates

t.test(attobo.pilot$EffortVar, attobo.pilot$AptVar, paired = TRUE)
## 
##  Paired t-test
## 
## data:  attobo.pilot$EffortVar and attobo.pilot$AptVar
## t = 6.7284, df = 201, p-value = 1.749e-10
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
##  0.5424520 0.9922014
## sample estimates:
## mean of the differences 
##               0.7673267
t.test(attobo.pilot$StratVar, attobo.pilot$AptVar,paired = TRUE)
## 
##  Paired t-test
## 
## data:  attobo.pilot$StratVar and attobo.pilot$AptVar
## t = 5.0449, df = 200, p-value = 1.016e-06
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
##  0.3363848 0.7680928
## sample estimates:
## mean of the differences 
##               0.5522388
t.test(attobo.pilot$StratVar, attobo.pilot$EffortVar, paired = TRUE)
## 
##  Paired t-test
## 
## data:  attobo.pilot$StratVar and attobo.pilot$EffortVar
## t = -2.1059, df = 200, p-value = 0.03646
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
##  -0.42388006 -0.01393089
## sample estimates:
## mean of the differences 
##              -0.2189055

Bayesian Model - Variability

apt.var <- attobo.pilot$AptVar
eff.var <- attobo.pilot$EffortVar
strat.var <- attobo.pilot$StratVar

y <- c(apt.var, eff.var, strat.var)
grand.mean <- mean(y, na.rm = T)

attobo.pilot.datjags <- list(apt.var = apt.var, eff.var = eff.var, strat.var = strat.var, N = nrow(attobo.pilot), grand.mean = grand.mean)
attobo.pilot.datjags

Model Specification

attobo.pilot.model <- function() {
  for(i in 1:N){
    # lambda is mean and variance of the poisson distribution
    
    apt.var[i] ~ dnorm(mu.apt[i], sigma[i]) # fixing error from each participant to be the same
    eff.var[i] ~ dnorm(mu.eff[i], sigma[i])
    strat.var[i] ~ dnorm(mu.strat[i], sigma[i])
    sigma[i] ~ dgamma(.01, .01) # all errors come from same distribution
  
    diff[1, i] <- mu.eff[i] - mu.apt[i]
    diff[2, i] <- mu.strat[i] - mu.apt[i]
    diff[3, i] <- mu.strat[i] - mu.eff[i]

    #priors
    mu.apt[i] ~ dnorm(grand.mean, .01)
    mu.eff[i] ~ dnorm(grand.mean, .01)
    mu.strat[i] ~ dnorm(grand.mean, .01)
    
  }
   
  
}
attobo.pilot.params <- c("diff", "mu.apt", "mu.eff", "mu.strat", "sigma")
attobo.pilot.inits1 <-  list( "mu.apt" =  rep(grand.mean, 202),
                        "mu.eff" = rep(grand.mean, 202), 
                        "mu.strat" = rep(grand.mean, 202),
                        "sigma" = rep(1,202))
attobo.pilot.inits2 <- list( "mu.apt" =  rep(3.5, 202),
                        "mu.eff" = rep(3.5, 202), 
                        "mu.strat" = rep(3.5, 202),
                        "sigma" = rep(2,202))
attobo.pilot.inits3 <- list( "mu.apt" =  rep(5, 202),
                        "mu.eff" = rep(5, 202), 
                        "mu.strat" = rep(5, 202),
                        "sigma" = rep(3,202))
attobo.pilot.inits4 <- list( "mu.apt" =  rep(2.5, 202),
                        "mu.eff" = rep(2.5, 202), 
                        "mu.strat" = rep(2.5, 202),
                        "sigma" = rep(1,202))
attobo.pilot.inits5 <- list( "mu.apt" =  rep(6, 202),
                        "mu.eff" = rep(6, 202), 
                        "mu.strat" = rep(6, 202),
                        "sigma" = rep(5,202))

attobo.pilot.inits <- list(attobo.pilot.inits1, attobo.pilot.inits2,attobo.pilot.inits3, attobo.pilot.inits4,attobo.pilot.inits5)
set.seed(1128)
attobo.pilot.fit <- jags(data = attobo.pilot.datjags, inits = attobo.pilot.inits, parameters.to.save = attobo.pilot.params, 
                n.chains = 5, n.iter = 100000, n.burnin = 10000, model.file = attobo.pilot.model)

attobo.pilot.fit.upd <- update(attobo.pilot.fit, n.iter =1000)
attobo.pilot.fit.upd <- autojags(attobo.pilot.fit)
attobo.pilot.fit.mcmc <- as.mcmc(attobo.pilot.fit)
save(attobo.pilot.fit.mcmc, file = "attobo.pilot.var.mcmc.RData")
summary(attobo.pilot.fit.mcmc)

Convergence Diagnostics

load("attobo.pilot.var.mcmc.RData")
                    
#  15 traces
MCMCtrace(attobo.pilot.fit.mcmc[,1:15], ind = TRUE, pdf = FALSE )

autocorr.plot(attobo.pilot.fit.mcmc[1][,1:15], ask = FALSE)

autocorr.plot(attobo.pilot.fit.mcmc[2][,1:15], ask = FALSE)

autocorr.plot(attobo.pilot.fit.mcmc[3][,1:15], ask = FALSE)

autocorr.plot(attobo.pilot.fit.mcmc[4][,1:15], ask = FALSE)

autocorr.plot(attobo.pilot.fit.mcmc[5][,1:15], ask = FALSE)

Calculating quantiles

attobo.pilot.var <- as.data.frame(as.matrix(attobo.pilot.fit.mcmc))
save(attobo.pilot.var, file = "attobo.pilot.var.RData")
load("attobo.pilot.var.RData")

pred.diff <- attobo.pilot.var[, grep("diff[", colnames(attobo.pilot.var), fixed = T)]

## estimated difference for each participant
pred.diff <- pred.diff[, c(mixedsort(names(pred.diff)))]

diff.1 <- pred.diff[, 1:202]
diff.1$mean.1 <- apply(diff.1, 1, mean)

diff.2 <- pred.diff[, 203:404]
diff.2$mean.2 <- apply(diff.2, 1, mean)

diff.3 <- pred.diff[, 405:606]
diff.3$mean.3 <- apply(diff.3, 1, mean)

# no clear diff
quantile(diff.1$mean.1, probs = c(.025, .5, .975))
##      2.5%       50%     97.5% 
## 0.1445953 0.7116423 1.2778965
# no clear diff
quantile(diff.2$mean.2, probs = c(.025, .5, .975))
##        2.5%         50%       97.5% 
## -0.07458129  0.50111039  1.07501855
# no clear diff
quantile(diff.3$mean.3, probs = c(.025, .5, .975))
##       2.5%        50%      97.5% 
## -0.7719047 -0.2029202  0.3430603

Presenting Results

attobo.pilot.posterior.coefs.sum <- summarize(group_by(attobo.pilot.posterior.coefs.long, key),
                                        median_coef = median(value),
                                        lower_coef = quantile(value, probs = c(0.025)),
                                        upper_coef = quantile(value, probs = c(0.975)))
ggplot(data = attobo.pilot.posterior.coefs.sum, aes(x = median_coef, y = key)) + 
  geom_errorbarh(aes(xmin = lower_coef, xmax = upper_coef), height = 0.1) + 
  geom_point() + 
  geom_vline(xintercept = 0, linetype = "dashed") + 
  xlab("Posterior estimate") + ylab("") + 
  theme_bw()

Uncontrollability

Frequentist Estimates

t.test(attobo.pilot$EffortUncon, attobo.pilot$AptUncon, paired = TRUE)
## 
##  Paired t-test
## 
## data:  attobo.pilot$EffortUncon and attobo.pilot$AptUncon
## t = -6.7245, df = 201, p-value = 1.788e-10
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
##  -0.9987349 -0.5458196
## sample estimates:
## mean of the differences 
##              -0.7722772
t.test(attobo.pilot$StratUncon, attobo.pilot$AptUncon,paired = TRUE)
## 
##  Paired t-test
## 
## data:  attobo.pilot$StratUncon and attobo.pilot$AptUncon
## t = -6.1896, df = 201, p-value = 3.33e-09
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
##  -0.8681684 -0.4486633
## sample estimates:
## mean of the differences 
##              -0.6584158
t.test(attobo.pilot$StratUncon, attobo.pilot$EffortUncon, paired = TRUE)
## 
##  Paired t-test
## 
## data:  attobo.pilot$StratUncon and attobo.pilot$EffortUncon
## t = 1.4676, df = 201, p-value = 0.1438
## alternative hypothesis: true difference in means is not equal to 0
## 95 percent confidence interval:
##  -0.03911735  0.26684012
## sample estimates:
## mean of the differences 
##               0.1138614

Bayesian Model - Uncontrollability

apt.uncon <- attobo.pilot$AptUncon
eff.uncon <- attobo.pilot$EffortUncon
strat.uncon <- attobo.pilot$StratUncon

y <- c(apt.uncon, eff.uncon, strat.uncon)
grand.mean <- mean(y)

attobo.pilot.datjags <- list(apt.uncon = apt.uncon, eff.uncon = eff.uncon, strat.uncon = strat.uncon, N = nrow(attobo.pilot), grand.mean = grand.mean)
attobo.pilot.datjags

Model Specification

attobo.pilot.model <- function() {
  for(i in 1:N){
    # lambda is mean and variance of the poisson distribution
    
    apt.uncon[i] ~ dnorm(mu.apt[i], sigma[i]) # fixing error from each participant to be the same
    eff.uncon[i] ~ dnorm(mu.eff[i], sigma[i])
    strat.uncon[i] ~ dnorm(mu.strat[i], sigma[i])
    sigma[i] ~ dgamma(.01, .01) # all errors come from same distribution
  
    diff[1, i] <- mu.eff[i] - mu.apt[i]
    diff[2, i] <- mu.strat[i] - mu.apt[i]
    diff[3, i] <- mu.strat[i] - mu.eff[i]

    #priors
    mu.apt[i] ~ dnorm(grand.mean, .01)
    mu.eff[i] ~ dnorm(grand.mean, .01)
    mu.strat[i] ~ dnorm(grand.mean, .01)
    
  }
   
  
}
attobo.pilot.params <- c("diff", "mu.apt", "mu.eff", "mu.strat", "sigma")
attobo.pilot.inits1 <-  list( "mu.apt" =  rep(grand.mean, 202),
                        "mu.eff" = rep(grand.mean, 202), 
                        "mu.strat" = rep(grand.mean, 202),
                        "sigma" = rep(1,202))
attobo.pilot.inits2 <- list( "mu.apt" =  rep(3.5, 202),
                        "mu.eff" = rep(3.5, 202), 
                        "mu.strat" = rep(3.5, 202),
                        "sigma" = rep(2,202))
attobo.pilot.inits3 <- list( "mu.apt" =  rep(5, 202),
                        "mu.eff" = rep(5, 202), 
                        "mu.strat" = rep(5, 202),
                        "sigma" = rep(3,202))
attobo.pilot.inits4 <- list( "mu.apt" =  rep(2.5, 202),
                        "mu.eff" = rep(2.5, 202), 
                        "mu.strat" = rep(2.5, 202),
                        "sigma" = rep(1,202))
attobo.pilot.inits5 <- list( "mu.apt" =  rep(6, 202),
                        "mu.eff" = rep(6, 202), 
                        "mu.strat" = rep(6, 202),
                        "sigma" = rep(5,202))

attobo.pilot.inits <- list(attobo.pilot.inits1, attobo.pilot.inits2,attobo.pilot.inits3, attobo.pilot.inits4,attobo.pilot.inits5)
set.seed(1128)
attobo.pilot.fit <- jags(data = attobo.pilot.datjags, inits = attobo.pilot.inits, parameters.to.save = attobo.pilot.params, 
                n.chains = 5, n.iter = 100000, n.burnin = 10000, model.file = attobo.pilot.model)

attobo.pilot.fit.upd <- update(attobo.pilot.fit, n.iter =1000)
attobo.pilot.fit.upd <- autojags(attobo.pilot.fit)
attobo.pilot.fit.mcmc <- as.mcmc(attobo.pilot.fit)
save(attobo.pilot.fit.mcmc, file = "attobo.pilot.uncon.mcmc.RData")
summary(attobo.pilot.fit.mcmc)

Convergence Diagnostics

load("attobo.pilot.uncon.mcmc.RData")

#  15 traces
MCMCtrace(attobo.pilot.fit.mcmc[,1:15], ind = TRUE, pdf = FALSE )

autocorr.plot(attobo.pilot.fit.mcmc[1][,1:15], ask = FALSE)

autocorr.plot(attobo.pilot.fit.mcmc[2][,1:15], ask = FALSE)

autocorr.plot(attobo.pilot.fit.mcmc[3][,1:15], ask = FALSE)

autocorr.plot(attobo.pilot.fit.mcmc[4][,1:15], ask = FALSE)

autocorr.plot(attobo.pilot.fit.mcmc[5][,1:15], ask = FALSE)

Calculating quantiles

attobo.pilot.uncon <- as.data.frame(as.matrix(attobo.pilot.fit.mcmc))
save(attobo.pilot.uncon, file = "attobo.pilot.uncon.RData")
load("attobo.pilot.uncon.RData")

pred.diff <- attobo.pilot.uncon[, grep("diff[", colnames(attobo.pilot.uncon), fixed = T)]

## estimated difference for each participant
pred.diff <- pred.diff[, c(mixedsort(names(pred.diff)))]

diff.1 <- pred.diff[, 1:202]
diff.1$mean.1 <- apply(diff.1, 1, mean)

diff.2 <- pred.diff[, 203:404]
diff.2$mean.2 <- apply(diff.2, 1, mean)

diff.3 <- pred.diff[, 405:606]
diff.3$mean.3 <- apply(diff.3, 1, mean)

# no clear diff
quantile(diff.1$mean.1, probs = c(.025, .5, .975))
##       2.5%        50%      97.5% 
## -1.2669970 -0.7164202 -0.1566044
# no clear diff
quantile(diff.2$mean.2, probs = c(.025, .5, .975))
##        2.5%         50%       97.5% 
## -1.15577376 -0.61175759 -0.05511707
# no clear diff
quantile(diff.3$mean.3, probs = c(.025, .5, .975))
##       2.5%        50%      97.5% 
## -0.4601501  0.1003800  0.6518248

Presenting Results

attobo.pilot.posterior.coefs.sum <- summarize(group_by(attobo.pilot.posterior.coefs.long, key),
                                        median_coef = median(value),
                                        lower_coef = quantile(value, probs = c(0.025)),
                                        upper_coef = quantile(value, probs = c(0.975)))
ggplot(data = attobo.pilot.posterior.coefs.sum, aes(x = median_coef, y = key)) + 
  geom_errorbarh(aes(xmin = lower_coef, xmax = upper_coef), height = 0.1) + 
  geom_point() + 
  geom_vline(xintercept = 0, linetype = "dashed") + 
  xlab("Posterior estimate") + ylab("") + 
  theme_bw()